package com.bazaaroid.server.gae.core.ioc;

import javax.servlet.ServletContext;
import javax.servlet.ServletContextEvent;

import com.google.inject.Injector;
import com.google.inject.servlet.GuiceServletContextListener;

public class AppGuiceServletContextListener extends GuiceServletContextListener {

	private ServletContext contex;

	public ServletContext getContex() {
		return contex;
	}

	@Override
	public void contextDestroyed(final ServletContextEvent servletContextEvent) {
		contex = null;
		super.contextDestroyed(servletContextEvent);
	}

	@Override
	public void contextInitialized(final ServletContextEvent servletContextEvent) {
		contex = servletContextEvent.getServletContext();
		super.contextInitialized(servletContextEvent);
	}

	@Override
	protected Injector getInjector() {
		return GuiceFactory.getInjector();
	}
}
